package com.sojson.project.service.impl;

import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sojson.project.dao.OrderGoodsDao;
import com.sojson.project.entity.po.OrderGoods;
import com.sojson.project.service.OrderGoodsService;

/**
 * Service实现类
 * 
 * @author liu
 * @date 2021-03-16
 */
@Service
public class OrderGoodsServiceImpl implements OrderGoodsService {

    @Resource
    private OrderGoodsDao orderGoodsDaoImpl;

    /**
     * 单条插入
     * 
     * @param orderGoods
     * @return
     * @throws SQLException
     */
    @Override
    public int insert(OrderGoods orderGoods) {
        int insert = orderGoodsDaoImpl.insert(orderGoods);
        return insert;
    }

    /**
     * 批量插入
     * 
     * @param orderGoods
     * @return
     * @throws SQLException
     */
    @Override
    public int insertList(OrderGoods orderGoods) {
        int insertList = orderGoodsDaoImpl.insertList(orderGoods.getOrderGoodss());
        return insertList;
    }

    /**
     * 通过对象批量删除(物理删除)
     * 
     * @param orderGoods
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByDto(OrderGoods orderGoods) {
        int deleteByDto = orderGoodsDaoImpl.deleteByDto(orderGoods);
        return deleteByDto;
    }

    /**
     * 统计全部数量
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public int countAll() {
        int countAll = orderGoodsDaoImpl.countAll();
        return countAll;
    }

    /**
     * 查询所有
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public List<OrderGoods> findAll() {
        List<OrderGoods> findAll = orderGoodsDaoImpl.listAll();
        return findAll;
    }

    /**
     * 根据对象统计数量
     * 
     * @param orderGoods
     * @return
     * @throws SQLException
     */
    @Override
    public int countByDto(OrderGoods orderGoods) {
        int countByDto = orderGoodsDaoImpl.countByDto(orderGoods);
        return countByDto;
    }

    /**
     * 根据对象查询
     * 
     * @param orderGoods
     * @return
     * @throws SQLException
     */
    @Override
    public List<OrderGoods> findByDto(OrderGoods orderGoods) {
        List<OrderGoods> findByDto = orderGoodsDaoImpl.listByDto(orderGoods);
        return findByDto;
    }

    /**
     * 通过id删除(物理删除)
     * 
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteById(Integer id) {
        int deleteById = orderGoodsDaoImpl.deleteById(id);
        return deleteById;
    }

    /**
     * 通过id列表删除(物理删除)
     * 
     * @param ids
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByIdList(List<Integer> ids) {
        int deleteByIdList = orderGoodsDaoImpl.deleteByIdList(ids);
        return deleteByIdList;
    }

    /**
     * 通过id更新(全部更新)
     * 
     * @param orderGoods
     * @return
     * @throws SQLException
     */
    @Override
    public int updateById(OrderGoods orderGoods) {
        int updateById = orderGoodsDaoImpl.updateById(orderGoods);
        return updateById;
    }

    /**
     * 通过id列表更新(全部更新)(更新内容相同)
     * 
     * @param orderGoods
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticByIdList(OrderGoods orderGoods) {
        int updateStaticByIdList = orderGoodsDaoImpl.updateStaticByIdList(orderGoods);
        return updateStaticByIdList;
    }

    /**
     * 通过id列表更新(全部更新)(更新内容不相同)
     * 
     * @param orderGoods
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangeByIdList(OrderGoods orderGoods) {
        int updateChangeByIdList = orderGoodsDaoImpl.updateChangeByIdList(orderGoods.getOrderGoodss());
        return updateChangeByIdList;
    }

    /**
     * 通过id更新(局部更新)
     * 
     * @param orderGoods
     * @return
     * @throws SQLException
     */
    @Override
    public int updatePartialById(OrderGoods orderGoods) {
        int updatePartialById = orderGoodsDaoImpl.updatePartialById(orderGoods);
        return updatePartialById;
    }

    /**
     * 通过id列表更新(局部更新)(更新内容相同)
     * 
     * @param orderGoods
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticPartialByIdList(OrderGoods orderGoods) {
        int updateStaticPartialByIdList = orderGoodsDaoImpl.updateStaticPartialByIdList(orderGoods);
        return updateStaticPartialByIdList;
    }

    /**
     * 通过id列表更新(局部更新)(更新内容不相同)
     * 
     * @param orderGoods
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangePartialByIdList(OrderGoods orderGoods) {
        int updateChangePartialByIdList = orderGoodsDaoImpl.updateChangePartialByIdList(orderGoods.getOrderGoodss());
        return updateChangePartialByIdList;
    }

    /**
     * 通过id查询
     * 
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public OrderGoods findById(Integer id) {
        OrderGoods findById = orderGoodsDaoImpl.findById(id);
        return findById;
    }

    /**
     * 通过id列表查询
     * 
     * @param ids
     * @return
     * @throws SQLException
     */
    @Override
    public List<OrderGoods> findByIdList(List<Integer> ids) {
        List<OrderGoods> findByIdList = orderGoodsDaoImpl.findByIdList(ids);
        return findByIdList;
    }

    /**
     * 通过对象查询id列表
     * 
     * @param orderGoods
     * @return
     * @throws SQLException
     */
    @Override
    public List<Integer> findIdByDto(OrderGoods orderGoods) {
        List<Integer> findIdByDto = orderGoodsDaoImpl.findIdByDto(orderGoods);
        return findIdByDto;
    }

    /**
     * 清空数据(物理清空)
     * 
     * @throws SQLException
     */
    @Override
    public void clear() {
        orderGoodsDaoImpl.clear();
    }

    /**
     * 统计订单商品数量
     * 
     * @param orderNo
     * @return
     */
    @Override
    public int countNumByOrderNo(String orderNo) {
        return orderGoodsDaoImpl.countNumByOrderNo(orderNo);
    }

}